package com.gientech.sys.event;

import com.gientech.common.Result;
import com.gientech.common.enums.OperType;
import com.gientech.common.view.DataGrid;
import com.gientech.core.base.BaseController;
import com.gientech.core.log.annotation.OperLog;
import com.gientech.core.security.annotation.PreAuthorize;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Api(tags = "【1-24】事件")
@ApiSort(value = 124) // 排序号生成后要修改
@Validated
@RestController
@RequestMapping("/sys/event")
public class SysEventController extends BaseController {
    @Autowired
    private SysEventService sysEventService;

    /**
     * 【1】查询和分页
     *
     * @param sysEventDTO4List 查询DTO
     * @param bindingResult
     * @return
     */
    @ApiOperation(value = "查询和分页")
    @ApiOperationSupport(order = 1)
    @OperLog(title = "事件", operType = OperType.SEARCH)
    @PreAuthorize(hasAuth = "event") // 菜单id或功能id
    @PostMapping(value = "/list")
    public Result<DataGrid<SysEventVO>> list(@Valid @RequestBody SysEventDTO4List sysEventDTO4List, BindingResult bindingResult) {

        return Result.success(this.sysEventService.listEvent(sysEventDTO4List));
    }


}
